package com.yw.start.main;

import org.apache.log4j.PropertyConfigurator;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.yw.start.model.ModelManager;
import com.yw.util.spring.SpringApplicationContext;
import com.yw.util.spring.SpringFactory;



public class SystemLoader {
	public static void loadModel() {
		ModelManager manager = (ModelManager) SpringFactory
				.getBean("modelManager");
		manager.start();
	}

	@SuppressWarnings({ "unused" })
	public static void loadConfig(String path) {
		try {
			System.out.println("loader log4j config...");
			PropertyConfigurator.configure(path + "/config/Log4j.properties");
			System.out.println("loader spring config...");
			ApplicationContext context = new FileSystemXmlApplicationContext(
					"file://" + path + "/config/spring-*.xml");
			if (context != null) {
				SpringApplicationContext.setApplicationContext(context);
			} else {
				System.out.println("spring config file load error");
			}
		} catch (BeansException e) {
			System.err.println(e);
		}
	}
}
